package com.niit.xlztest.service;


import com.niit.xlztest.bean.Book;
import com.niit.xlztest.repository.BookRepository;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.time.LocalDateTime;
import java.util.List;

@Transactional
@Service("bookService")
public class BookServiceImpl implements BookService {


    @Autowired
    private BookRepository bookRepository;


    @Override
    public void addBook(Book book) {
        bookRepository.save(book);
    }
    @Override
    public void updateBook(Book book) {
        bookRepository.save(book);
    }
    @Override
    public void deleteBookById(Integer book_id) {
        bookRepository.deleteBookById(book_id);
    }

    @Override
    public List<Book> findAllBooks() {
        return (List<Book>) bookRepository.findAll();
    }

    @Override
    public List<Book> findBookByName(String bookName) {
        return null;
    }

    @Override
    public Book findBookByid(String book_id) {
        return bookRepository.findBookByid(book_id);
    }

    @Override
    public List<Book> findBookByType(String category) {
        return (List<Book>) bookRepository.findBookByType(category);
    }

//    @Override
//    public List<Comm> findUserByName(String userName) {
//        return null;
//    }
//
//    @Override
//    public List<Comm> findCommByid(String comm_id) {
//        return (List<Comm>) commRepository.findCommByid(comm_id);
//    }

}
